﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 学生绩效
{
    delegate void ShowData(string dataPath);
    public partial class detaiFrm : Form
    {
        ShowData showData;
        FormXueye frmxy;
        SerialPort sp = new SerialPort();
        private string _datatype;
        public detaiFrm(FormXueye xy,string dataType)
        {
            InitializeComponent();
            frmxy = xy;
            Datatype = dataType;
            this.FormBorderStyle = FormBorderStyle.None;
            this.BackColor = Color.Black;
            this.StartPosition = FormStartPosition.CenterScreen;
            this.Width = Screen.PrimaryScreen.WorkingArea.Width;
            this.Height = Screen.PrimaryScreen.WorkingArea.Height;
            
            
        }
        public string Datatype { get => _datatype; set => _datatype = value; }
        Image imgTitle;
        DataTable dt;

        private void detaiFrm_Load(object sender, EventArgs e)
        {
            Image img = Image.FromFile(@"pictures/return.png");
            label4.Image = img;
            label4.ImageAlign = ContentAlignment.MiddleCenter;
            
            if (frmxy.Choice == "xueye")
            {
                imgTitle = Image.FromFile(@"pictures/Title.png");
                //pictureBox1.Image = imgTitle;
                dt = ExcelOpe.ReadMYEXCEL( "shuju.xls");
                dataGridView1.DataSource = dt.AsDataView();
                foreach (DataGridViewColumn g in dataGridView1.Columns)
                {
                    g.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
            }
            else if (frmxy.Choice == "zhiye")
            {
                imgTitle = Image.FromFile(@"pictures/TitleNew.png");
                pictureBox1.Image = imgTitle;
                dt = ExcelOpe.ReadMYEXCELNew("shuju.xls");
                dataGridView1.DataSource = dt.AsDataView();
                foreach (DataGridViewColumn g in dataGridView1.Columns)
                {
                    g.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
                }
            }
        }


        private void label4_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
